home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / d_d / caltech / inbound / mcm / mcm.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-22  |  7.5 KB  |  270 lines

  1. /* MCM  -  MultiUser Communications Manager
  2.  
  3.    Copyright (C) 1991,2 Michael Sawyer
  4.  
  5.    This code may be reproduced without charge provided that this
  6.    notice remains intact on all copies distributed.
  7.  
  8.    Any part of this code may be used in other programs provided that
  9.    some citation of this work is given.
  10. */
  11.  
  12. /* Configuration section */
  13.  
  14.  /* Ultrix is BSD */
  15.  /* If you are running BSD, make sure BSD gets defined somehow! */
  16.  
  17. #ifdef ultrix
  18. #ifndef BSD
  19. #define BSD
  20. #endif
  21. #endif
  22.  
  23.  /* If you are not using an ANSI compiler, need to define NOANSI */
  24.  /* Assume worst case for defined() syntax */
  25. #ifndef ANSI
  26. #ifndef NOANSI
  27. #define NOANSI
  28. #endif
  29. #endif
  30.  
  31.  /* Define this for machines (BSD) who need usleep() provided for them */
  32. #ifdef BSD
  33. #define NEED_USLEEP
  34. #endif
  35.  
  36.  /* For usleep() machines, set the number of microseconds to sleep */
  37.  /* while waiting for data */
  38. #define DELAYTIME 25
  39.  
  40.  /* How nice do we want MCM to run? */
  41. #define HOWNICE 5
  42.  
  43.  /* How many jobs will we allow on the server at any time? */
  44. #define NUMJOBS 32
  45.  
  46.  /* If defines, this variable controls how often (in seconds) the MCM */
  47.  /* server will time-stamp the session.  This time-stamp appears in */
  48.  /* both the logfiles as well as to all users logged in. */
  49. #define DELTAT 1800
  50.  
  51.  /* If you do not want the ability to use the termcap libraries to */
  52.  /* provide full-screen support, comment this out. */
  53.  /* curses support is completly remved from this version */
  54. #define TERMCAP /* Termcap support */
  55.  
  56.  /* If your compiler has trouble with bitfields (none should), define this: */
  57. /*#define BADBITS*/
  58.  
  59.  /* If you want name padding to be on by default, uncomment this. */
  60. /*#define DFNAMEPAD */
  61.  
  62.  /* If you want job numbers by default, uncomment */
  63. #define DFJOBNUMS
  64.  
  65.  /* If you want counts by default, uncomment */
  66. /*#define DFCOUNTS */
  67.  
  68. /* END of user configuration... */
  69.  
  70.  
  71.  
  72. #define VERSION "mcm 1.1e [Beta] (C) 1991,2 Inlet Software/Michael Sawyer"
  73.  
  74. #include <signal.h>
  75. #ifndef BSD
  76. #include <sys/file.h>
  77. #endif
  78. #include <sys/types.h>
  79. #include <sys/socket.h>
  80. #include <sys/time.h>
  81. #include <sys/resource.h>
  82. #include <netinet/in.h>
  83. #include <arpa/inet.h>
  84. #include <unistd.h>
  85. #include <netdb.h>
  86. #include <errno.h>
  87. #include <stdio.h>
  88. #include <ctype.h>
  89. #include <fcntl.h>
  90. #include <string.h>
  91. #ifdef CURSES
  92. #include <curses.h>
  93. #else
  94. #include <sys/ioctl.h>
  95. #endif /* CURSES */
  96. /* Just to make sure they exist... */
  97. #ifndef TRUE
  98. #define TRUE (1==1)
  99. #define FALSE (1==0)
  100. #endif
  101.  
  102. #ifdef NOANSI
  103. #define _PARAMS(x) ()
  104. #else
  105. #define _PARAMS(x) x
  106. #endif
  107.  
  108. #ifdef BADBITS
  109. #define _BIT(x,y) x
  110. #else
  111. #define _BIT(x,y) x:y
  112. #endif
  113.  
  114. extern int errno;
  115.  
  116. #define validjob(jobid) (!((jobid<0)||(jobid>NUMJOBS)))
  117.  
  118. /* And some prototypes */
  119.  
  120. void bailout _PARAMS((int, char*));
  121. void sigprocessor _PARAMS((int));
  122. int main _PARAMS((int, char**));
  123. void check_connections _PARAMS(());
  124. int communicate _PARAMS(());
  125. void tell  _PARAMS((int, int, char*, char*));
  126. void process _PARAMS((int, char*));
  127. void loginuser _PARAMS((int));
  128. void strcap _PARAMS((char*));
  129. void starcommand _PARAMS((int, char*));
  130. void slashcommand _PARAMS((int, char*));
  131. void endsession _PARAMS((int));
  132. void whothere _PARAMS((int, char*));
  133. void gagpeople _PARAMS((int, char*));
  134. void privconf _PARAMS((int, char*));
  135. void rolldice _PARAMS((int, char*, int));
  136. void sendmsg _PARAMS((int, char*));
  137. void typefile _PARAMS((int, char*));
  138. void wwrap _PARAMS((char*));
  139. void txout _PARAMS((int, int, char*, char*, int));
  140. void easytext _PARAMS((int, int, char*, char*, int));
  141. void strcap _PARAMS((char*));
  142. void struncap _PARAMS((char*));
  143. void listenonly _PARAMS((int, char*));
  144. void sendmsg _PARAMS((int, char*));
  145. void doormessage _PARAMS((int, char*));
  146. void dowins _PARAMS((int, char*));
  147. void endsession _PARAMS((int));
  148. void usertype _PARAMS((int, char*));
  149. void userhelp _PARAMS((int, char*));
  150. void modecommand _PARAMS((int,char*));
  151. void setasst _PARAMS((char*));
  152. void set_count _PARAMS((int, char*));
  153. void set_jobid _PARAMS((int, char*));
  154. void set_namepad _PARAMS((int,char*));
  155.  
  156. #ifdef NEED_USLEEP
  157. int usleep _PARAMS((unsigned long));
  158. #endif
  159.  
  160. #ifdef CURSES
  161. void splinit _PARAMS((int, char*));
  162. void splend _PARAMS((int));
  163. void spltext _PARAMS((int,int,char*, char*, int));
  164. void splredraw _PARAMS((int));
  165. void splfollow _PARAMS((int));
  166. void splnewinp _PARAMS((int));
  167. void swwrap _PARAMS((char*));
  168. #endif
  169. #ifdef TERMCAP
  170. void splinit _PARAMS((int,char*));
  171. char *depad _PARAMS((char*));
  172. void splend _PARAMS((int));
  173. void spltxout _PARAMS((int,char*));
  174. void spltext _PARAMS((int,int,char*,char*,int));
  175. void splredraw _PARAMS((int));
  176. void splchar _PARAMS((int,char));
  177. void splbackup _PARAMS((int));
  178. void splnewinp _PARAMS((int));
  179. void set_lines _PARAMS((int,int));
  180.  
  181. /* The Termcap routines themselves */
  182. int tgetent _PARAMS((char*,char*));
  183. int tgetnum _PARAMS((char*));
  184. char *tgetstr _PARAMS((char*,char**));
  185. char *tgoto _PARAMS((char*,int,int));
  186. #endif
  187.  
  188. /* Stuff from the personality modules */
  189. void per_init ();
  190. void per_sig2 ();
  191. void per_timestep();
  192. int per_tell _PARAMS((int, int, char*, char*));
  193. int per_process _PARAMS((int, char*));
  194. void per_login _PARAMS((int));
  195. int per_starhelp _PARAMS((int));
  196. int per_slashhelp _PARAMS((int));
  197. int per_mode _PARAMS((int, char*));
  198. int per_modehelp _PARAMS((int));
  199. int per_preroll _PARAMS((int, char*));
  200. int per_postroll _PARAMS((int, int, char*, int, int, int, int*));
  201. void per_logout _PARAMS((int));
  202.  
  203. struct JOB
  204. {
  205.   int fd; /* a file descriptor for the socket */
  206.   char buf[255]; /* Text buffer */
  207.   char name[20]; /* Name of the user */
  208.   char pass[20]; /* The password used */
  209.   char from[48]; /* Name of host system */
  210.   char extra[64]; /* Some extra info */
  211.   unsigned char addrs[4]; /* Address of user's machine */
  212.   unsigned int _BIT(width,8), /* Line width */
  213.       _BIT(mode,2), /* 0=None, 1=name:, 2=pass:, 3=Normal */
  214.       _BIT(firstrun,1), /* First run through process (CONNECT message) */
  215.       _BIT(gagged,1), /* User is gagged */
  216.       _BIT(privconf,1), /* User in private conf. */
  217.       _BIT(maybeleader,1), /* User may becode leader */
  218.       _BIT(showcount,1), /* Show the count of messages */
  219.       _BIT(showjob,1), /* Show job IDs */
  220.       _BIT(padname,1), /* Pad names */
  221.       _BIT(userbt0,1), /* User Bit 0 (for pers. modules) */
  222.       _BIT(userbt1,1), /* User bit 1 */
  223.       _BIT(userbt2,1), /* User bit 2 */
  224.       _BIT(userbt3,1), /* User bit 3 */
  225.       _BIT(userby0,8), /* User byte 0 */
  226.       _BIT(userby1,8), /* User byte 1 */
  227.       _BIT(userby2,8), /* User byte 2 */
  228.       _BIT(userby3,8), /* User byte 3 */
  229.       _BIT(userby4,8), /* User byte 4 */
  230.       _BIT(userby5,8), /* User byte 5 */
  231.       userwd0, /* User word 0 */
  232.       userwd1; /* User word 1 */
  233.   char userstr[32]; /* User string */
  234.   /* Stuff for CURSES */
  235. #ifdef CURSES
  236.   FILE *fp;
  237.   SCREEN *basescr;
  238.   WINDOW *rootwin, *inpwin, *outwin;
  239. #endif
  240.   /* Now stuff for termcap/info */
  241. #ifdef TERMCAP
  242.   char al[32], bc[32], cd[32], ce[32], cl[32], dc[32], dl[32], so[32], se[32];
  243.   char sr[32], cm[32], cs[32], rs[32], xdo[32];
  244.   int co, li;
  245.   char termtype[32];
  246. #endif
  247. };
  248.  
  249. /* Global variables */
  250.  
  251. struct JOB job[NUMJOBS];
  252.  
  253. char msgtext[1024]; /* Message for the door */
  254. int s; /* The socket */
  255. struct servent *ps; /* Server entry */
  256. struct sockaddr_in sin; /* Socket address */
  257. int portid; /* ID of the port */
  258. int msgcount; /* Counter of message numbers */
  259. int listen_mode, /* -1 = floor opened, # = uid with floor */
  260.     whogagged, /* List gagged users */
  261.     defaultgag, /* New users are gagged as they enter */
  262.     snoopmode, /* Snoop on private messages */
  263.     confhear, /* Can conf users hear? */
  264.     conftalk, /* Can they talk? */
  265.     asstleader; /* Ass't room leader */
  266. FILE *masterfp, *logfp;
  267.  
  268. /* EOF mcm.h */
  269.  
  270.